//
//  DayExpress.m
//  TengyunStation
//
//  Created by Johnny on 15/8/27.
//  Copyright (c) 2015年 xingrong. All rights reserved.
//

#import "DayExpress.h"
#import "SocketMethod.h"

@implementation DayExpress

- (id)initWithString:(NSString *)string {
    self = [super init];
    if (self) {
        NSArray *array = [string componentsSeparatedByString:@","];
        self.expressday = [SocketMethod subArray:array Index:0];
        self.expressCount = [[SocketMethod subArray:array Index:1] intValue];
    }
    return self;
}

- (void)setExpressListString:(NSString *)string {
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:1];
    NSArray *array = [string componentsSeparatedByString:@"|"];
    for (NSString *sonString in array) {
        if (sonString.length > 0) {
            DayEveryExpress *dayEveryExpress = [[DayEveryExpress alloc] initWithString:sonString];
            [mutableArray addObject:dayEveryExpress];
        }
    }
    self.isOpen = YES;
    self.expressList = mutableArray;
}

- (void)setExpressday:(NSString *)expressday {
    _expressday = expressday;
    if (expressday.length > 0) {
        NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
        dateFormatter1.dateFormat = @"yyyyMMdd";
        NSDate *date = [dateFormatter1 dateFromString:expressday];
        NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init];
        dateFormatter2.dateFormat = @"MM月dd日";
        self.showDay = [dateFormatter2 stringFromDate:date];
    }
}

@end

@implementation DayEveryExpress

- (id)initWithString:(NSString *)string {
    self = [super init];
    if (self) {
        NSArray *array = [string componentsSeparatedByString:@","];
        self.expressCompanyName = [SocketMethod subArray:array Index:0];
        self.expressId = [SocketMethod subArray:array Index:1];
    }
    return self;
}

@end
